var __extends =
    (this && this.__extends) ||
    (function () {
      var t = function (n, e) {
        return (t =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (t, n) {
              t.__proto__ = n;
            }) ||
          function (t, n) {
            for (var e in n)
              Object.prototype.hasOwnProperty.call(n, e) && (t[e] = n[e]);
          })(n, e);
      };
      return function (n, e) {
        function i() {
          this.constructor = n;
        }
        if ("function" != typeof e && null !== e)
          throw new TypeError(
            "Class extends value " + String(e) + " is not a constructor or null"
          );
        t(n, e),
          (n.prototype =
            null === e
              ? Object.create(e)
              : ((i.prototype = e.prototype), new i()));
      };
    })(),
  CommonInputSelectDialog = (function (t) {
    function n() {
      var n = t.call(this) || this;
      return (
        (n.max = 99),
        (n.min = 1),
        (n.step = 1),
        (n.num = 1),
        n.btn_com_input_sure.on(Laya.Event.CLICK, n, n.onDidClickSureAction),
        n.slide_com_input_sel.on(
          Laya.Event.CHANGE,
          n,
          n.onSliderCommonInputChange
        ),
        n.btn_com_acc.on(Laya.Event.CLICK, n, n.onDidClickItemFn),
        n.btn_com_dec.on(Laya.Event.CLICK, n, n.onDidClickItemFn),
        n.text_input_com.on(Laya.Event.BLUR, n, n.onDidTextChangeAction),
        n.text_input_com.on(Laya.Event.FOCUS, n, n.onDidTextChangeAction),
        n
      );
    }
    return (
      __extends(n, t),
      (n.showCommonInputDialog = function (t, e) {
        null == this.comInputV &&
          ((this.comInputV = new n()), (this.comInputV.zOrder = 2e3)),
          this.comInputV.popup(!0),
          (this.comInputV.type = t),
          "矿石合成" == t
            ? ((this.comInputV.label_input_select_title.text = "矿石合成"),
              (this.comInputV.label_com_content.text =
                e.oreName + "(" + e.num + "个)"),
              (this.comInputV.label_com_tips.text = "消耗数量"),
              (this.comInputV.jsonDict = e),
              (this.comInputV.max = e.num),
              (this.comInputV.min = 2),
              (this.comInputV.text_input_com.text = "2"),
              (this.comInputV.max = parseInt(e.num)),
              (this.comInputV.slide_com_input_sel.max = e.num),
              (this.comInputV.slide_com_input_sel.value = 2),
              (this.comInputV.btn_com_input_sure.label = "合成"),
              (this.comInputV.btn_com_input_sure.skin =
                "comp/commonpic/btn_dialog_sure.png"))
            : "矿石回收" == t &&
              ((this.comInputV.label_input_select_title.text = "矿石回收"),
              (this.comInputV.label_com_content.text =
                e.oreName + "(" + e.num + "个)"),
              (this.comInputV.label_com_tips.text = "回收数量"),
              (this.comInputV.jsonDict = e),
              (this.comInputV.max = e.num),
              (this.comInputV.min = 1),
              (this.comInputV.text_input_com.text = "1"),
              (this.comInputV.max = parseInt(e.num)),
              (this.comInputV.slide_com_input_sel.max = e.num),
              (this.comInputV.slide_com_input_sel.value = 1),
              (this.comInputV.btn_com_input_sure.label = "回收"),
              (this.comInputV.btn_com_input_sure.skin =
                "comp/preload/btn_com_close.png"));
      }),
      (n.prototype.onDidClickSureAction = function () {
        if ("矿石合成" == this.type) {
          if (
            this.text_input_com.text.length <= 0 ||
            this.text_input_com.text.length <= 0
          )
            return void ToastView.toastView("请输入数量");
          t = this.text_input_com.text + "";
          WebSocketService.send({
            c: 12911,
            d: { type: 2, goodsId: this.jsonDict.goodsId, num: t },
          }),
            this.close();
        } else if ("矿石回收" == this.type) {
          if (
            this.text_input_com.text.length <= 0 ||
            this.text_input_com.text.length <= 0
          )
            return void ToastView.toastView("请输入数量");
          var t = this.text_input_com.text + "";
          WebSocketService.send({
            c: 1296,
            d: { id: this.jsonDict.goodsId, count: t },
          }),
            this.close();
        }
      }),
      (n.prototype.onSliderCommonInputChange = function () {
        this.slide_com_input_sel.value < 2 &&
          ((this.text_input_com.text = "2"),
          (this.slide_com_input_sel.value = 2)),
          (this.num = this.slide_com_input_sel.value),
          (this.text_input_com.text = this.slide_com_input_sel.value + "");
      }),
      (n.prototype.onDidClickItemFn = function (t) {
        "item0" == t.target.name
          ? ((this.num = this.num - this.step),
            this.num < this.min && (this.num = this.min),
            (this.slide_com_input_sel.value = this.num))
          : "item1" == t.target.name &&
            ((this.num = this.num + this.step),
            this.num > this.max && (this.num = this.max),
            (this.slide_com_input_sel.value = this.num)),
          (this.text_input_com.text = this.slide_com_input_sel.value + "");
      }),
      (n.prototype.onDidTextChangeAction = function (t) {
        console.log(t.target);
        var n = parseInt(this.text_input_com.text);
        n > this.max && (this.text_input_com.text = this.max + ""),
          n < 2 &&
            ((this.text_input_com.text = "2"),
            (this.slide_com_input_sel.value = 2));
      }),
      n
    );
  })(ui.common.CommonInputSelectDialogUI);
